<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<style>
    .jiada{font-size: 14px;font-weight: bold}
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">证书名称</label>
                        <div class="layui-input-block">
                            <input type="text" id="name" name="name" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">证书专业</label>
                        <div class="layui-input-block">
                            <input type="text" id="major" name="major" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <input type="hidden" id="type" name="type" value="">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" style="margin-bottom: 20px;">
                <div class="layui-card">
                    <div class="layui-card-body">
                        <table class="layui-table">
                            <tbody><tr><td colspan="5" style="font-size: 14px;"><b>企业主要人员状况：</b></td></tr></tbody>
                            <tbody id="qirendata"></tbody>
                        </table>
                    </div>
                </div>
            </div>

            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <!-- <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a> -->
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    function jump_cert(type, name) {
        openNavPage('查看人员证书信息','cert/index.php?type='+type+'&cert_name='+encodeURIComponent(name));
    }

    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        var jishu=0;
        facade.ajax({url: ask_cert_qiren_list}).done(function(res){
            if (res.code === 2000) {
                var data = res.data;
                var str = '';
                for (var mmm in data){
                    str += '<tr><td colspan="5" class="jiada">'+data[mmm].name+'（'+data[mmm].nums+'）</td></tr>';


                    var children = data[mmm].children;
                    for (var nnn in children){
                        if(nnn%5 == 0){
                            jishu = 1;
                            str += '<tr>';
                        }else{
                            jishu++;
                        }
                        str += '<td><a class="colorlan" onclick="jump_cert(\''+data[mmm].value+'\',\''+children[nnn].name+'\')">'+children[nnn].name+'（'+children[nnn].nums+'）</a></td>';
                        if(nnn%5 == 0 && jishu ==5){
                            str += '</tr>';
                        }
                    }

                    for (var iii=1; iii<=5-jishu; iii++){
                        str += '<td></td>';
                    }
                    if(5-jishu > 0){
                        str += '</tr>';
                    }

                }
                $("#qirendata").html(str);
                render_from();
            }
        });




        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });
        setSouTableExport('人员证件统计');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_cert_tong_list),where: {}, page: true, height: 'full-100'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                xiala_zhan_two('cert_type', res.data.type, '', 'value','name');
                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.total,
                    "data": res.data.data
                };
            }
            , cols: [[
                {type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field: 'name', title: '证书名称',rowspan:2}
                ,{field: 'majornew', title: '证书专业',rowspan:2}
                ,{field: 'caitype_name', title: '现有数量',colspan:5,align:'center'}
                ,{field: 'year', title: '使用情况',colspan:2,align:'center'}
            ],[
                {field:'nums',title:'合计',totalRow: true,event: 'nums',templet: function(d){return '<span class="colorlan">'+d.nums+'</span>';}}
                ,{field:'nature_quan',title:'全职',totalRow: true,event: 'nature_quan',templet: function(d){return '<span class="colorlan">'+d.nature_quan+'</span>';}}
                ,{field:'nature_wai',title:'外聘',totalRow: true,event: 'nature_wai',templet: function(d){return '<span class="colorlan">'+d.nature_wai+'</span>';}}
                ,{field:'nature_xiang',title:'项目部',totalRow: true,event: 'nature_xiang',templet: function(d){return '<span class="colorlan">'+d.nature_xiang+'</span>';}}
                ,{field:'nature_lin',title:'临时',totalRow: true,event: 'nature_lin',templet: function(d){return '<span class="colorlan">'+d.nature_lin+'</span>';}}

                ,{field:'statueuse_kong',title:'空闲',totalRow: true,event: 'statueuse_kong',templet: function(d){return '<span class="colorlan">'+d.statueuse_kong+'</span>';}}
                ,{field:'statueuse_zai',title:'在用',totalRow: true,event: 'statueuse_zai',templet: function(d){return '<span class="colorlan">'+d.statueuse_zai+'</span>';}}
            ]
            ]
            , done: function (res) {
                soulTable.render(this);
            }
        });

        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'nums'){
                openNavPage('查看人员证书信息','cert/index.php?cert_name='+encodeURIComponent(data.name)+'&cert_major='+encodeURIComponent(data.majornew));
            }
            if(obj.event === 'nature_quan'){
                openNavPage('查看人员证书信息','cert/index.php?cert_name='+encodeURIComponent(data.name)+'&cert_major='+encodeURIComponent(data.majornew)+'&nature='+encodeURIComponent('全职'));
            }
            if(obj.event === 'nature_wai'){
                openNavPage('查看人员证书信息','cert/index.php?cert_name='+encodeURIComponent(data.name)+'&cert_major='+encodeURIComponent(data.majornew)+'&nature='+encodeURIComponent('外聘'));
            }
            if(obj.event === 'nature_xiang'){
                openNavPage('查看人员证书信息','cert/index.php?cert_name='+encodeURIComponent(data.name)+'&cert_major='+encodeURIComponent(data.majornew)+'&nature='+encodeURIComponent('项目部'));
            }
            if(obj.event === 'nature_lin'){
                openNavPage('查看人员证书信息','cert/index.php?cert_name='+encodeURIComponent(data.name)+'&cert_major='+encodeURIComponent(data.majornew)+'&nature='+encodeURIComponent('临时'));
            }

            if(obj.event === 'statueuse_kong'){
                openNavPage('查看人员证书信息','cert/index.php?cert_name='+encodeURIComponent(data.name)+'&cert_major='+encodeURIComponent(data.majornew)+'&statueuse='+encodeURIComponent('空闲'));
            }
            if(obj.event === 'statueuse_zai'){
                openNavPage('查看人员证书信息','cert/index.php?cert_name='+encodeURIComponent(data.name)+'&cert_major='+encodeURIComponent(data.majornew)+'&statueuse='+encodeURIComponent('在用'));
            }
        });
        listTableSearch(form, table);
    });



</script>
</body>
</html>
